<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var mailService = document.getElementById("mailService");
		var SMTPPort = document.getElementById("SMTPPort");
		var userName = document.getElementById("userName");
		var password = document.getElementById("password");
		
		if(mailService.value == ""){
			alert("邮件服务器不能为空！");
			return false;
		}
		if(SMTPPort.value == ""){
			alert("SMTP服务器端口不能为空！");
			return false;
		}
		if(userName.value == ""){
			alert("邮件帐户不能为空！");
			return false;
		}else{
			if(!isEmail(userName)){
				alert("输入的邮件帐户格式不正确!");
				return false;
			}
		}
		if(password.value == ""){
			alert("邮件密码不能为空！");
			return false;
		}
		return true;
	}

	function save(){
		if(checkForm()){
			document.dataInterfaceForm.action = "./dataInterface.do?action=updateDataterface";
			document.dataInterfaceForm.target = "main";
			document.dataInterfaceForm.submit();
			
			document.getElementById("save").href = "#";
		}
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			alert("已保存！如果设置成功，则该邮件帐户将收到设置成功提示；如果没收到设置成功提示，则表示当前设置不正确。");
		}
		
		document.getElementById("save").href = "javascript:save();";
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="dataInterfaceForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" colspan="2">数据接口</td>
					</tr>
					<tr>
						<td valign="bottom" class="a_tools" style="padding-left: 3px;">
							<a name="save" class="save" href="javascript:save();" title="保存" hidefocus="true">保存</a>
						</td>
						<td></td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td>
							<table class="table_add">
								<tr>
									<td class="title">邮件服务器：</td>
									<td width="28%"><input id="mailService" name="mailService" class="input_long" type="text" value="${dataInterface.mailService}"/></td>
									<td>&nbsp;&nbsp;例如：your_mail_service.com</td>
									<td></td>
								</tr>
								<tr>
									<td class="title">SMTP服务器端口：</td>
									<td><input id="SMTPPort" name="SMTPPort" class="input_long" type="text" value="${dataInterface.SMTPPort}"/></td>
									<td>&nbsp;&nbsp;默认端口：25</td>
									<td></td>
								</tr>
								<tr>
									<td class="title">邮件帐户：</td>
									<td><input id="userName" name="userName" class="input_long" type="text" value="${dataInterface.userName}"/></td>
									<td>&nbsp;&nbsp;例如：your_mail@feeyin.com</td>
									<td></td>
								</tr>
								<tr>
									<td class="title">邮件密码：</td>
									<td><input id="password" name="password" class="input_long" type="password" value="${dataInterface.password}"/></td>
									<td colspan="2"></td>
								</tr>
								<tr><td colspan="4">注：如需要邮件提醒，服务器必须能够上网。</td></tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<input id="id" name="id" type="hidden" value="${dataInterface.id}"/>
</form>
</body>
</html>